package com.bit.dreamer;

import android.app.ActionBar;
import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.TabHost;
import android.widget.Toast;

public class DreaminsertActivity extends TabActivity {
	
	 SharedPreferences sf;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		final TabHost tabHost = getTabHost();
		
		ActionBar actionbar = getActionBar();
		sf = getSharedPreferences("name", MODE_PRIVATE);
		String nName = sf.getString("name", "");
		actionbar.setTitle(nName + "님 안녕하세요");
		actionbar.setDisplayShowHomeEnabled(false);
		
		
		Intent int1 = new Intent(this, Dreaminsert_doActivity.class);
		int1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		tabHost.addTab(tabHost.newTabSpec("tab1")
				.setIndicator("하고")
				.setContent(int1));

		Intent int2 = new Intent(this, Dreaminsert_haveActivity.class);
		int1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		tabHost.addTab(tabHost.newTabSpec("tab2")
				.setIndicator("갖고")
				.setContent(int2));
	
		Intent int3 = new Intent(this, Dreaminsert_becomeActivity.class);
		int1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		tabHost.addTab(tabHost.newTabSpec("tab3")
				.setIndicator("되고")
				.setContent(int3));
		
		switch (getIntent().getIntExtra("sel", 0)) {
		case 1:
			tabHost.setCurrentTab(0);
			break;
			
		case 2:
			tabHost.setCurrentTab(1);
			break;
			
		case 3:
			tabHost.setCurrentTab(2);
			break;

		}
		
	}	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		
		// Inflate the menu; this adds items to the action bar if it is present.
//		getMenuInflater().inflate(R.menu.lotto_main, menu);
//		return true;
		
		super.onCreateOptionsMenu(menu);
		
		MenuItem item = menu.add(0, 1, 0, "로그인");
		item.setIcon(R.drawable.ic_launcher);
		item.setAlphabeticShortcut('a'); // 키보드 a를 누르면 실행되게끔
		
		menu.add(0, 2, 0, "꿈목록");
		menu.add(0, 3, 0, "꿈지도");
		menu.add(0, 4, 0, "메뉴들");
		
		//menu.add(0, 5, 0, "도움말");  // 축소로 주석
	
	return true;
	}
	

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch ( item.getItemId()){
		case 1:
			Intent intent1= new Intent(getApplicationContext(), MainActivity.class);
			startActivity(intent1);
			
			Toast.makeText(this, "로그인 화면 가기", Toast.LENGTH_SHORT).show();
			return true;

		case 2 :
			Intent intent2= new Intent(getApplicationContext(), MainMenuActivity.class);
			startActivity(intent2);
			Toast.makeText(this, "나의 꿈 목록 보기", Toast.LENGTH_SHORT).show();
			return true;

		case 3 :
			Intent intent3= new Intent(getApplicationContext(), DreamMap.class);
			startActivity(intent3);
			
			Toast.makeText(this, "나의 꿈 지도 보기", Toast.LENGTH_SHORT).show();
			return true;

		case 4 :
			Intent intent4= new Intent(getApplicationContext(), com.bit.dreamer.SubMenu.class);
			startActivity(intent4);
			Toast.makeText(this , "다양한 메뉴들 보기", Toast.LENGTH_SHORT).show();
			return true;
			
//		case 5 :  //축소로 주석
//			Intent intent5= new Intent(getApplicationContext(), PrologueActivity.class);
//			startActivity(intent5);
//			Toast.makeText(this, "도움말", Toast.LENGTH_SHORT).show();
//			return true;

		}

		return false;

	}
	
}


